package com.tm.d10_time;

import java.time.Clock;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Set;

/**
 * 2024/5/24 Cjj ZonedDateTime  15：39
 */
public class Test3_ZoneId_ZonedDateTime {
    public static void main(String[] args) {
        //目标：了解时区和带时区的时间
        //1.ZoneId的常见方法：
         //public static ZoneId systemDefault():获取系统默认的时区
        ZoneId zoneId = ZoneId.systemDefault();
        System.out.println(zoneId.getId());

        //public static Set<String> getAvailableZoneIds():获取Java支持的全部时区Id
        Set<String> availableZoneIds = ZoneId.getAvailableZoneIds();
        System.out.println(availableZoneIds);

        //public static ZoneId of(String zoneId):把某个时区id封装成ZoneId对象
        ZoneId id = ZoneId.of("America/Cuiaba");
        System.out.println(id);

        //2.ZonedDateTime: 带时区的时间
        //public static ZonedDateTime now(ZoneId zone):获取某个时区的ZoneDateTime对象
        ZonedDateTime now = ZonedDateTime.now(id);
        System.out.println(now);

        //世界标准时间
        //public static ZonedDateTime.now 获取系统默认时区的ZonedDateTime对象
        ZonedDateTime time = ZonedDateTime.now(Clock.systemUTC());
        System.out.println(time);

        System.out.println(ZonedDateTime.now());
    }
}
